package cn.growthgate.fgo.service.impl;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;

import cn.growthgate.fgo.common.base.BaseServiceImpl;
import cn.growthgate.fgo.common.base.BaseVo;
import cn.growthgate.fgo.entity.Servant;
import cn.growthgate.fgo.entity.vo.ServantVo;
import cn.growthgate.fgo.mapper.ServantMapper;
import cn.growthgate.fgo.service.IServantService;

/**
 * <p>
 * 从者 服务实现类
 * </p>
 *
 * @author GrowthGate
 * @since 2019-05-20
 */
@Service
public class ServantServiceImpl extends BaseServiceImpl<ServantMapper, Servant> implements IServantService {

	@Override
	public BaseVo<Servant> transformVo(Servant entity) {
		ServantVo vo = new ServantVo();
		vo.setId(entity.getId());
		vo.setGameId(entity.getGameId());
		vo.setName(entity.getName());
		vo.setStar(entity.getStar());
		vo.setCost(entity.getCost());
		vo.setClazz(baseMapper.getClass(entity));
		vo.setInitialHp(entity.getInitialHp());
		vo.setInitialAtk(entity.getInitialAtk());
		vo.setFullLevelHp(entity.getFullLevelHp());
		vo.setFullLevelAtk(entity.getFullLevelAtk());
		vo.setHundredHp(entity.getHundredHp());
		vo.setHundredAtk(entity.getHundredAtk());
		vo.setAvatar(entity.getAvatar());
		vo.setNpColorCard(entity.getNpColorCard());
		vo.setNpType(entity.getNpType());
		if (entity.getCards() != null) {
			vo.setCards(entity.getCards().getColorCards());
		}
		vo.setHeight(entity.getHeight());
		vo.setWeight(entity.getWeight());
		vo.setStrength(entity.getStrength());
		vo.setEndurance(entity.getEndurance());
		vo.setAgility(entity.getAgility());
		vo.setMana(entity.getMana());
		vo.setLuck(entity.getLuck());
		vo.setNpLevel(entity.getNpLevel());
		vo.setNpQuick(entity.getNpQuick());
		vo.setNpArts(entity.getNpArts());
		vo.setNpBuster(entity.getNpBuster());
		vo.setNpExtra(entity.getNpExtra());
		vo.setNpNp(entity.getNpNp());
		vo.setNpSuffer(entity.getNpSuffer());
		vo.setHitQuick(entity.getHitQuick());
		vo.setHitArts(entity.getHitArts());
		vo.setHitBuster(entity.getHitBuster());
		vo.setHitExtra(entity.getHitExtra());
		vo.setHitNp(entity.getHitNp());
		vo.setStarRate(entity.getStarRate());
		vo.setBeKilled(entity.getBeKilled());
		vo.setCollectingStars(entity.getCollectingStars());
		return vo;
	}

	@Override
	public Page<Servant> selectJoinCv(Integer current, Integer size, String orderByField, Boolean isAsc,
			Wrapper<Servant> wrapper) {
		Page<Servant> page = constPage(current, size, orderByField, isAsc, wrapper, "s");
		return page.setRecords(baseMapper.selectJoinCv(page, wrapper));
	}

}
